home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 3
/
CU Amiga Magazine's Super CD-ROM 03 (1996)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1996-09].iso
/
misc
/
readers_utils
/
aslplaysound
/
soundplayer.s
< prev
next >
Wrap
Text File
|
1992-09-02
|
6KB
|
316 lines
*Sound Play
*By Mark Retallack
* ensure case dependent and debug
opt c+,d+
* firstly get the required constants and macros
include dos/dos_lib.i include dos commands
include dos/dos.i include dos workings
include exec/exec_lib.i
* setup library offsets
FSGetSize EQU -30
FSLoadSound EQU -36
FSPlaySound EQU -42
FSStopSound EQU -48
CALLFU MACRO
move.l _futurebase,a6
jsr FS\1(a6)
ENDM
* firstly open the Future library
lea funame(pc),a1 store funame in a1
moveq #0,d0 dont care which version
CALLEXEC OpenLibrary
tst.l d0 test d0 and set flag z if lib was opened
beq gofast if flag z is not set goto goawayfast
move.l d0,_futurebase store lib pointer
*open dos library
lea dosname(pc),a1 store dosname in a1
moveq #0,d0 dont care which version
CALLEXEC OpenLibrary
tst.l d0 test d0 and set flag z if lib was opened
beq goclosefu if flag z is not set goto goawayfast
move.l d0,_DOSBase store lib pointer
*set handle
CALLDOS Output Call output
move.l d0,_stdout Move address to stdout
CALLDOS Input
move.l d0,_stdin
*write to dos
move.l _stdout,d1 DOS output file handle
move.l #messa,d2 start of message
move.l #sizeofmessa,d3 size of message
CALLDOS Write DOS call to write message
flab move.l _stdout,d1 DOS output file handle
move.l #messg,d2 start of message
move.l #sizeofmessg,d3 size of message
CALLDOS Write DOS call to write message
*Read Name of file
move.l _stdin,d1
move.l #messb,d2
move.l #40,d3
CALLDOS Read
lea messb,a0
subi #1,d0
move.l d0,d7
move.l #0,(a0,d0)
*get the size of the file
lea messb,a0
CALLFU GetSize
tst.l d0
bne pass
move.l _stdout,d1 DOS output file handle
move.l #messj,d2 start of message
move.l #sizeofmessj,d3 size of message
CALLDOS Write DOS call to write message
move.l _stdout,d1 DOS output file handle
move.l #messb,d2 start of message
move.l d7,d3 size of message
CALLDOS Write DOS call to write message
move.l _stdout,d1 DOS output file handle
move.l #messi,d2 start of message
move.l #sizeofmessi,d3 size of message
CALLDOS Write DOS call to write message
bra vlab
pass
move.l d0,d6
*free memory
move.l d6,d0
move.l #65538,d1
CALLEXEC AllocMem
tst.l d0
bne passs
move.l _stdout,d1 DOS output file handle
move.l #messj,d2 start of message
move.l #sizeofmessj,d3 size of message
CALLDOS Write DOS call to write message
move.l _stdout,d1 DOS output file handle
move.l #messb,d2 start of message
move.l d7,d3 size of message
CALLDOS Write DOS call to write message
move.l _stdout,d1 DOS output file handle
move.l #messk,d2 start of message
move.l #sizeofmessk,d3 size of message
CALLDOS Write DOS call to write message
bra vlab
passs
move.l d0,d5
*load in sound
move.l d5,a0
move.l #messb,d0
CALLFU LoadSound
tst.l d0
beq gofreemem
move.l d0,d4
*caluclate the period
move.l #3579545,d1
divu d4,d1
move.l d1,d4
*playsound
slab move.l d5,a0
move.l d6,d0
move.l #1,d1
move.l d4,d2
move.l #64,d3
CALLFU PlaySound
move.l d0,d7
*write choice message
move.l _stdout,d1 DOS output file handle
move.l #messc,d2 start of message
move.l #sizeofmessc,d3 size of message
CALLDOS Write DOS call to write message
*read choice
move.l _stdin,d1
move.l #messd,d2
move.b #2,d3
CALLDOS Read
*stop sound
move.l d7,a0
CALLFU StopSound
*look at choice
move.b #'y',d0
cmp.b messd,d0
beq slab
*free memory
gofreemem
move.l d5,a1
move.l d6,d0
CALLEXEC FreeMem
*ask if wants to load new
vlab move.l _stdout,d1 DOS output file handle
move.l #messe,d2 start of message
move.l #sizeofmesse,d3 size of message
CALLDOS Write DOS call to write message
*get answer
move.l _stdin,d1
move.l #messf,d2
move.b #2,d3
CALLDOS Read
*look at answer
move.b #'y',d0
cmp.b messf,d0
beq flab
*print last message
move.l _stdout,d1 DOS output file handle
move.l #messh,d2 start of message
move.l #sizeofmessh,d3 size of message
CALLDOS Write DOS call to write message
*close dos lib
goclosedos
move.l _DOSBase,a1
CALLEXEC CloseLibrary
* finished so close future library
goclosefu
move.l _futurebase,a1
CALLEXEC CloseLibrary
gofast
moveq #0,d0
rts
*set up handle
_stdout ds.l 1 Set handle
_stdin ds.l 1
* strings here
funame dc.b 'future.library',0 name of future lib
dosname dc.b 'dos.library',0
* variables here
_futurebase dc.l 0 for future library
_DOSBase dc.l 0
*messages
messa dc.b 'Sound Player',10,'By Mark Retallack',10,'Plays IFF sound files using the Future Library',10
sizeofmessa equ *-messa
messc dc.b 'Play Again? (y/n): '
sizeofmessc equ *-messc
messb ds.b 40
messd ds.b 2
messe dc.b 10,'Do you want to load a new sound (y/n): '
sizeofmesse equ *-messe
messf ds.b 2
messg dc.b 10,'Enter Name Of File: '
sizeofmessg equ *-messg
messh dc.b 10,'Bye, Bye',10
sizeofmessh equ *-messh
messi dc.b 10,'File Dose Not Exist.',10
sizeofmessi equ *-messi
messj dc.b 10,'Cannot load file: '
sizeofmessj equ *-messj
messk dc.b 10,'Not an IFF file.',10
sizeofmessk equ *-messk